<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<div class="block medium left">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        <h2>Details of building "<bean:write name="building" property="buildingName"/>"</h2>
    </div>
    <!-- .block_head ends -->
    
    <div class="block_content clearfix">
        <html:form styleId="buildingForm" action="admin/building.do" method="post">
            
            <logic:notEmpty name="errorMessages" >
                <div class="message errormsg">
                    <logic:iterate id="message" name="errorMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <logic:notEmpty name="successMessages" >
                <div class="message success">
                    <logic:iterate id="message" name="successMessages">
                        <p><bean:write name="message"/></p>
                    </logic:iterate>
                </div>
            </logic:notEmpty>
            <h2>Land</h2><br/>
                        <p>
                <html:hidden property="landID" />
                <label>ID: </label>
                <span class="text"><bean:write name="land" property="landID"/></span>
            </p>
            <p>
                <label>Address: </label>
                <span class="text"><bean:write name="land" property="address"/></span>
            </p>
            <p>
                <label>Location: </label>
                <span class="text"><bean:write name="land" property="locationName"/></span>
            </p>
            <p>
                <label>Plan Laid: </label>
                <span class="text"><bean:write name="land" property="planName"/></span>
            </p>
            <p>
                <label>Area: </label>
                <span class="text"><bean:write name="land" property="landArea"/>
                &nbsp;sq.foot</span>
            </p>
            <p>
                <label>Near by (Landmarks): </label>
                <span class="text"><bean:write name="land" property="nearByLandMarks"/></span>
            </p>
            <hr/>
            <br/><br/>
            <h2>Building</h2><br/>
            <p>
                <html:hidden property="action" value="UpdateStatus"/>
                <label>Status: </label>
                <span class="text"><bean:write name="building" property="statusName"/>.&nbsp;&nbsp;&nbsp;
                    <logic:equal name="building" property="statusCode" value="CR">
                        <html:hidden property="statusCode" value="CC"/>
                        Update status: <html:submit value="Completely Constructed" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="building" property="statusCode" value="CC">
                        <html:hidden property="statusCode" value="AO"/>
                        Update status: <html:submit value="Applied Occupancy Permit" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="building" property="statusCode" value="AO">
                        <html:hidden property="statusCode" value="RO"/>
                        <html:hidden property="permitType" value="occupancy"/>
                        Update status: <html:submit value="Received Occupancy Permit" styleClass="submit longer"/>
                    </logic:equal>
                    <logic:equal name="building" property="statusCode" value="RO">
                        <html:hidden property="statusCode" value="BS"/>
                        Update status: <html:submit value="To Be Sold" styleClass="submit mid"/>
                    </logic:equal>
                    <logic:equal name="building" property="statusCode" value="BS">
                        <html:hidden property="statusCode" value="S"/>
                        Update status: <html:submit value="Sold" styleClass="submit"/>
                    </logic:equal>
                </span>
            </p>
            <p>
                <label>Last Status Changed On: </label><span class="text"><fmt:formatDate type="both" value="${building.statusChangedDate}"/></span>                
            </p>
            <hr/>
            <p>
                <html:hidden property="buildingID" />
                <label>ID: </label>
                <span class="text"><bean:write name="building" property="buildingID"/></span>
            </p>
            <p>
                <label>Building Name: </label>
                <span class="text"><bean:write name="building" property="buildingName"/></span>
            </p>
            <p>
                <label>Building Type </label>
                <span class="text"><bean:write name="building" property="typeName"/></span>
            </p>
            <p>
                <label>Number of floors: </label>
                <span class="text"><bean:write name="building" property="numFloors"/></span>
            </p>
            <p>
                <label>Number of rooms: </label>
                <span class="text"><bean:write name="building" property="numFloors"/></span>
            </p>
            <p>
                <label>Constructed On: </label>
                <span class="text"><fmt:formatDate type="date" value="${building.constructedDate}"/></span>
            </p>
            <p><label>Description:</label></p>
            <div>
                ${building.description}
            </div>
        </html:form>
        
        <hr/>
        
        <html:form styleId="buildingForm" action="admin/building.do" method="post">
            <p>
                <html:hidden property="buildingID" />
                <html:submit property="action" value="Edit" styleClass="submit"/>
                <html:link styleClass="confirm-button submit small red" action="/admin/buildingListing.do?action=delete" paramId="buildingID" paramName="buildingForm" paramProperty="buildingID">
                    Delete
                </html:link>
                <html:link action="/admin/buildingListing.do" styleClass="submit long gray">Back to the list</html:link>
            </p>
        </html:form>
        
        
    </div>
    <!-- .block_content ends -->
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block.medium.left ends -->


<div class="block tiny right">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <h2>Status History</h2>
    </div>
    <!-- .block_head ends -->

    
    <div class="block_content clearfix">
        
        <table cellpadding="0" cellspacing="0" width="100%" class="sortable">
            <thead>
                <th>Status</th>
                <th>Changed On</th>
            </thead>
            <tbody>
                <logic:iterate id="status" name="statusHistory">
                    <tr>
                        <td><bean:write name="status" property="statusName"/></td>
                        <td><fmt:formatDate type="both" value="${status.changedDate}"/></td>
                    </tr>
                </logic:iterate>
            </tbody>
            
        </table>
        
    </div>
    <!-- .block_content ends -->
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block.tiny.right ends -->


<div class="block tiny right">
    
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        
        <h2>Permits</h2>
    </div>
    <!-- .block_head ends -->

    
    <div class="block_content clearfix">
        
        <logic:present name="occupancyPermit">
            <h2>Occupancy Permit</h2>
            <html:form action="admin/building.do">
                <div>
                    <p>
                        <label>Issuer Name: </label>
                        <span class="text">
                            ${occupancyPermit.issuerName}
                        </span>
                    </p>
                    <p>
                        <label>Issued Date</label>
                        <span class="text">
                            <fmt:formatDate type="date" value="${occupancyPermit.issuedDate}"/>
                        </span>
                    </p>
                    <p>
                        <label>Signer Name: </label>
                        <span class="text">
                            ${occupancyPermit.signerName}
                        </span>
                    </p>
                    <p>
                        <label>Description: </label>
                    </p>
                    <div>
                        ${occupancyPermit.description}
                    </div>
                    <html:hidden property="buildingID" />
                    <html:hidden property="action" value="editOP"/>
                    <html:hidden property="permitType" value="occupancy"/>
                    <p> <html:submit value="Edit" styleClass="submit small"/></p>
                </div>
            </html:form>
        </logic:present>
        <logic:notPresent name="occupancyPermit">
            <p class="align-center">There are no permits.</p>
        </logic:notPresent>
        
    </div>
    <!-- .block_content ends -->
    
    <div class="bendl"></div>
    <div class="bendr"></div>
    
</div>
<!-- .block.tiny.right ends -->